<template>
  <Dialog v-model="dialogVisible" title="考评员资质详情" width="800px">
    <el-descriptions :column="2" border>
      <el-descriptions-item label="考评员姓名">
        {{ evaluatorData.evaluatorName || evaluatorData.userName || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="考评员编码">
        {{ evaluatorData.evaluatorCode || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="用户邮箱">
        {{ evaluatorData.userEmail || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="用户手机">
        {{ evaluatorData.userMobile || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="部门名称">
        {{ evaluatorData.deptName || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="职业代码">
        {{ evaluatorData.professionCodes || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="职业名称">
        {{ evaluatorData.professionName || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="技能等级">
        {{ evaluatorData.skillLevels || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="资质等级">
        {{ evaluatorData.qualificationLevel || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="资质状态">
        <el-tag :type="evaluatorData.qualificationStatus === 1 ? 'success' : 'danger'">
          {{ evaluatorData.qualificationStatus === 1 ? '有效' : '无效' }}
        </el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="证书编号">
        {{ evaluatorData.certificateNumber || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="发证机构">
        {{ evaluatorData.certificateIssuer || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="发证日期">
        {{ evaluatorData.certificateDate || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="有效期至">
        {{ evaluatorData.validUntil || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="专业领域">
        {{ evaluatorData.specialties || '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="最大工作负荷">
        {{ evaluatorData.maxWorkload ? evaluatorData.maxWorkload + '人次/月' : '-' }}
      </el-descriptions-item>
      <el-descriptions-item label="创建时间" :span="2">
        {{ formatDateTime(evaluatorData.createTime) }}
      </el-descriptions-item>
    </el-descriptions>
    
    <template #footer>
      <el-button @click="dialogVisible = false">关闭</el-button>
    </template>
  </Dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { formatDateTime } from '@/utils/formatTime'
import * as EvaluatorApi from '@/api/eval/evaluator'

const dialogVisible = ref(false)
const evaluatorData = ref<any>({})

/** 打开弹窗 */
const open = async (id: number) => {
  dialogVisible.value = true
  try {
    const data = await EvaluatorApi.getEvaluatorQualification(id)
    evaluatorData.value = data
  } catch (error) {
    console.error('获取考评员详情失败:', error)
  }
}

defineExpose({ open })
</script> 